import { EventDefinition } from '@/types/event';
import { dispatchActions } from '../action';
import Node from '../core/Node';

export const triggerEvent = (nodes: Node[] = []) => {
  console.log('click fired', nodes);
  nodes.forEach((o) => {
    const clickEvents = o.config.events.filter((p: EventDefinition) => p.name === 'click');
    clickEvents.forEach((p: EventDefinition) => {
      const actions = p.actions || [];
      dispatchActions(actions);
    });
  });
};
